﻿<UserControl x:Class="Mengsk.ERP.App.AddressCheck.AddressCheckUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
    <UserControl.Resources>
        <Style x:Key="OrderDataGridStyle" TargetType="{x:Type DataGrid}">
            <Setter Property="AutoGenerateColumns" Value="false"/>
            <Setter Property="CanUserAddRows" Value="false"/>
            <Setter Property="CanUserDeleteRows" Value="false"/>
            <Setter Property="CanUserReorderColumns" Value="false"/>
            <Setter Property="CanUserResizeRows" Value="false"/>
            <Setter Property="IsReadOnly" Value="true"/>
            <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
            <Setter Property="RowHeight" Value="18"/>
            <Setter Property="SelectionMode" Value="Extended"/>
            <Setter Property="SelectionUnit" Value="CellOrRowHeader"/>
            <Setter Property="RowHeaderWidth" Value="45"/>
            <Setter Property="RowHeaderStyle">
                <Setter.Value>
                    <Style TargetType="{x:Type DataGridRowHeader}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <StackPanel Orientation="Horizontal" Background="LightGray"  HorizontalAlignment="Right">
                                        <TextBlock Text="{Binding Expander}" VerticalAlignment="Center" HorizontalAlignment="Center" Background="LightGray" ></TextBlock>
                                        <Image Source="{Binding Flag}" Stretch="Fill" Width="16" Height="16" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                    </StackPanel>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>

            <Setter Property="RowDetailsTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <ListBox Visibility="{Binding RowDetailVisibility}" ItemsSource="{Binding Order.Items}">
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="ListBoxItem">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ListBoxItem">
                                                <Border BorderBrush="LightBlue" BorderThickness="3">
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock Margin="3" Text="{Binding InternalName}"/>
                                                        <TextBlock Margin="3" Text="{Binding Edtion}"/>
                                                        <TextBlock Margin="3" Text="{Binding Color}"/>
                                                        <TextBlock Margin="3" Text="{Binding Size}"/>
                                                        <TextBlock Margin="3" Text="{Binding Money}"/>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListBox.ItemContainerStyle>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel/>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                    </DataTemplate>
                </Setter.Value>
            </Setter>

            <Setter Property="RowStyle">
                <Setter.Value>
                    <Style TargetType="{x:Type DataGridRow}">
                        <Setter Property="Background" Value="{Binding Background}"/>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="3*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>

        <ListBox MinHeight="30" Visibility="Collapsed"
                                     Name="lstShops" 
                                     ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                                     ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                                     SelectionMode="Extended" >
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <StackPanel Orientation="Horizontal" Margin="3,0,0,0">
                                    <CheckBox IsChecked="{Binding Path=Checked}" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding OrderManager.Type}" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="-" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding OrderManager.ShopName}" Margin="3" VerticalAlignment="Center"/>
                                </StackPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>

        <StackPanel Orientation="Horizontal" Grid.Row="1" ></StackPanel>

        <StackPanel Orientation="Horizontal" Grid.Row="2" >
            <Ellipse Width="20" Height="20" Fill="Red" Margin="3" />
            <TextBlock Text="拒收或者退货" Margin="3" VerticalAlignment="Center"/>
            <Ellipse Width="20" Height="20" Fill="Yellow" Margin="3" />
            <TextBlock Text="重复下单" Margin="3" VerticalAlignment="Center"/>
            <Ellipse Width="20" Height="20" Fill="LightBlue" Margin="3" />
            <TextBlock Text="地址含村" Margin="3" VerticalAlignment="Center"/>
            <Button Name="btnRefresh" Margin="3" VerticalAlignment="Center" Width="60" Content="刷新" Click="btnRefresh_Click" />
            <TextBlock Name="tbTotal" Margin="3" VerticalAlignment="Center" />
        </StackPanel>

        <DataGrid Grid.Row="3" Name="dgvOrders" Margin="3" Style="{StaticResource ResourceKey=OrderDataGridStyle}" AutoGenerateColumns="False" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" SelectionChanged="dgvOrders_SelectionChanged">
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="标记为 圆到" Name="miYTArrive" Click="miYTArrive_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Green.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="标记为 宅到" Name="miZhaiArrive" Click="miZhaiArrive_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Blue.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <Separator Height="3"/>
                    <MenuItem Header="标记为 圆到回头客" Name="miYTArriveAndReturn" Click="miYTArriveAndReturn_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Green.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="标记为 宅到回头客" Name="miZhaiArriveAndReturn" Click="miZhaiArriveAndReturn_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Blue.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator Height="3"/>
                    <MenuItem Header="标记为 圆到镇" Name="miYTArrvieTown" Click="miYTArrvieTown_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Yellow.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="标记为 宅到镇" Name="miZhaiArriveTown" Click="miZhaiArriveTown_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Yellow.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator Height="3"/>
                    <MenuItem Header="标记为 圆到县" Name="miYTArrvieCountry" Click="miYTArrvieCountry_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Yellow.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="标记为 宅到县" Name="miZhaiArriveCountry" Click="miZhaiArriveCountry_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Yellow.jpg" Stretch="Fill" Height="12" Width="12" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator Height="3"/>
                    <MenuItem Header="标记为 地址不明" Name="miAddressNotClear" Click="miAddressNotClear_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Yellow.jpg" Stretch="Fill" Height="12" Width="12" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator Height="3"/>
                    <MenuItem Header="标记为 不到" Name="noneArrvie" Click="noneArrvie_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Red.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="标记为 不到关" Name="noneArrvieAndClose" Click="noneArrvieAndClose_Click">
                        <MenuItem.Icon>
                            <Image Source="/Mengsk.ERP;component/Orders/Images/Red.jpg" Stretch="Fill" Height="12" Width="12"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator Height="3"/>
                    <MenuItem Header="启动 手动标记" Name="startManualEdit" Click="startManualEdit_Click"/>
                    <MenuItem Header="启动 多客户端" Name="startPPCRM" Click="startPPCRM_Click"/>
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridTextColumn Header="商铺信息" Width="Auto" Binding="{Binding Shop}"/>
                <DataGridTextColumn Header="用户编号" Width="Auto" Binding="{Binding Order.Name}"/>
                <DataGridTextColumn Header="真实姓名" Width="Auto" Binding="{Binding Order.RealName}"/>
                <DataGridTextColumn Header="购买信息" Width="Auto" Binding="{Binding Item}"/>
                <DataGridTextColumn Header="下单时间" Width="Auto" Binding="{Binding Order.CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                <DataGridTextColumn Header="联系方式" Width="Auto" Binding="{Binding Phone}"/>
                <DataGridTextColumn Header="收货地址" Width="Auto" Binding="{Binding Order.Address}"/>
                <DataGridTextColumn Header="买家描述" Width="Auto" Binding="{Binding Order.BuyerComment}"/>
                <DataGridTextColumn Header="卖家描述" Width="*" Binding="{Binding SellerComment}"/>
            </DataGrid.Columns>
        </DataGrid>

        <GridSplitter Grid.Row="4" Height="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
        
        <DataGrid Name="dgvHistoryItem" Margin="3" Grid.Row="6"  Style="{StaticResource ResourceKey=OrderDataGridStyle}">
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="关闭订单" Name="historyClose" Click="historyClose_Click"/>
                    <MenuItem Header="启动手动标记" Name="historyCloseStartManualEdit" Click="historyCloseStartManualEdit_Click"/>
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridTextColumn Header="商铺信息" Width="Auto" Binding="{Binding Shop}"/>
                <DataGridTextColumn Header="用户编号" Width="Auto" Binding="{Binding Order.Name}"/>
                <DataGridTextColumn Header="真实姓名" Width="Auto" Binding="{Binding Order.RealName}"/>
                <DataGridTextColumn Header="购买信息" Width="Auto" Binding="{Binding Item}"/>
                <DataGridTextColumn Header="下单时间" Width="Auto" Binding="{Binding Order.CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                <DataGridTextColumn Header="订单状态" Width="Auto" Binding="{Binding State}"/>
                <DataGridTextColumn Header="曾用物流" Width="Auto" Binding="{Binding Order.DeliveryCompany}"/>
                <DataGridTextColumn Header="联系方式" Width="Auto" Binding="{Binding Phone}"/>
                <DataGridTextColumn Header="收货地址" Width="Auto" Binding="{Binding Order.Address}"/>
                <DataGridTextColumn Header="买家描述" Width="Auto" Binding="{Binding Order.BuyerComment}"/>
                <DataGridTextColumn Header="卖家描述" Width="*" Binding="{Binding SellerComment}"/>
            </DataGrid.Columns>
        </DataGrid>
   

    </Grid>
</UserControl>
